/**
 *
 */
package com.hybris.msig.paymentgateway.adapters.telemoney;

import java.util.HashMap;
import java.util.Map;

import com.hybris.msig.paymentgateway.adapters.AbstractIPaymentGatewayAdapter;
import com.hybris.msig.paymentgateway.dto.MsigPayRequestDto;


/**
 * @author i313922
 *
 */
public class TelemoneyGatewayAdapter extends AbstractIPaymentGatewayAdapter
{
	private static final String DEFAULT_RCARD = "64";

	private String mid;

	private String requestPage;

	private String returnUrl;

	private String statusUrl;

	private String clientStatusPageUrl;

	/*
	 * (non-Javadoc)
	 *
	 * @see com.hybris.msig.paymentgateway.adapters.IPaymentGatewayAdapter#paymentRequestPage()
	 */
	@Override
	public String paymentRequestPage()
	{
		System.out.println("requestPage : " + requestPage);
		return requestPage;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.hybris.msig.paymentgateway.adapters.IPaymentGatewayAdapter#build3rdPaymentRequest(com.hybris.msig.
	 * paymentgateway.dto.MsigPayRequestDto)
	 */
	@Override
	public Map<String, Object> build3rdPaymentRequest(final MsigPayRequestDto msigPayRequestDto)
	{
		final Map<String, Object> result = new HashMap<>();
		result.put("mid", mid);
		result.put("ref", msigPayRequestDto.getRefid());
		result.put("cur", msigPayRequestDto.getCur());
		//TODO:Need to check amt?
		result.put("amt", msigPayRequestDto.getAmt());

		//TODO:refator with standard API
		result.put("returnurl", returnUrl + "?portalCode=" + msigPayRequestDto.getPortalCode() + "&clientReturnUrl="
				+ msigPayRequestDto.getSuccessURL() + "&refid=" + msigPayRequestDto.getRefid());
		result.put("statusurl", statusUrl);
		// display certain parts of card number display in clear: valid values : 60, 64, 04
		result.put("rcard", DEFAULT_RCARD);
		// user specified field, use the first one as PortalCode
		result.put("userfield1", msigPayRequestDto.getPortalCode());

		return result;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.hybris.msig.paymentgateway.adapters.IPaymentGatewayAdapter#paymentStatusPage()
	 */
	@Override
	public String paymentStatusPage()
	{
		System.out.println("clientStatusPageUrl : " + clientStatusPageUrl);
		return clientStatusPageUrl;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * com.hybris.msig.paymentgateway.adapters.AbstractIPaymentGatewayAdapter#buildUpdatePaymentTransactionParameters(
	 * java.util.Map)
	 */
	//	@Override
	//	protected PaymentResponseData buildUpdatePaymentTransactionParameters(final Map<String, String[]> callbackParameters)
	//	{
	//		// YTODO Auto-generated method stub
	//		return null;
	//	}

	/**
	 * @return the requestPage
	 */
	public String getRequestPage()
	{
		return requestPage;
	}

	/**
	 * @param requestPage
	 *            the requestPage to set
	 */
	public void setRequestPage(final String requestPage)
	{
		this.requestPage = requestPage;
	}

	/**
	 * @return the statusUrl
	 */
	public String getStatusUrl()
	{
		return statusUrl;
	}

	/**
	 * @param statusUrl
	 *            the statusUrl to set
	 */
	public void setStatusUrl(final String statusUrl)
	{
		this.statusUrl = statusUrl;
	}

	/**
	 * @return the returnUrl
	 */
	public String getReturnUrl()
	{
		return returnUrl;
	}

	/**
	 * @param returnUrl
	 *            the returnUrl to set
	 */
	public void setReturnUrl(final String returnUrl)
	{
		this.returnUrl = returnUrl;
	}

	/**
	 * @return the mid
	 */
	public String getMid()
	{
		return mid;
	}

	/**
	 * @param mid
	 *            the mid to set
	 */
	public void setMid(final String mid)
	{
		this.mid = mid;
	}

	/**
	 * @return the clientStatusPageUrl
	 */
	public String getClientStatusPageUrl()
	{
		return clientStatusPageUrl;
	}

	/**
	 * @param clientStatusPageUrl
	 *            the clientStatusPageUrl to set
	 */
	public void setClientStatusPageUrl(final String clientStatusPageUrl)
	{
		this.clientStatusPageUrl = clientStatusPageUrl;
	}

}